/*  extMDB 1.1 - an extension to gvSIG Desktop GIS to read GeoMedia MDB warehouses
 *  Copyright (C) 2008-2009  Stefano Orlando
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * Revision 1.1  02/05/09 Stefano Orlando
 * Revision 1.0  06/02/09 Stefano Orlando
 */
package com.iver.cit.gvsig.mdb.core;

import com.iver.andami.PluginServices;
/**
 * Exception thrown when an error occurs converting the GeoMedia geometry
 * types to JTS geometry types.
 * @author Stefano Orlando
 */
public class MDBAdapterException extends Exception {

	private static final long serialVersionUID = 3867899745422033590L;
	
	private String msg;
	
	public MDBAdapterException(String msg) {
		super();
		this.msg = formatMessage(msg);
	}
	
	public MDBAdapterException(String msg, Throwable cause) {
		super(cause);
		this.msg = formatMessage(msg);
	}
	
	public MDBAdapterException(Throwable cause) {
		super(cause);
	}
	
	public String getMessage() {
		return this.msg;
	}
	
	private String formatMessage(String msg) {
		
		if (msg.equalsIgnoreCase("malformed_geom_error"))
			return PluginServices.getText(this,"malformed_geom_error");
		
		else if (msg.equalsIgnoreCase("unknown_geom_error"))
			return PluginServices.getText(this,"unknown_geom_error");
		
		else if (msg.equalsIgnoreCase("unsupported_geom_error"))
			return PluginServices.getText(this,"unsupported_geom_error");
		
		return null;
	}
}
